import { Middleware } from 'koa'

const globalExceptionMid: Middleware = async (ctx, next) => {
  try {
    await next()
  } catch (error) {
    const err = error as Error
    ctx.fail(`服务器错误: ${err.message}`)
  }
}

export default globalExceptionMid
